//
//  MyScoreViewController.m
//  wtshoppingcite
//
//  Created by TW on 14-10-24.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "MyScoreViewController.h"
#import "MyScoreDetailViewController.h"
#import "AppDelegate.h"

@interface MyScoreViewController ()

@property(retain,nonatomic)NSArray *titleArray;

@end

@implementation MyScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.titleArray = @[@"详情",@"分数",@"次数",@"总计"];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self setTitleView:@"我的积分"];
    
    UIView *scoreView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 30)];
    scoreView.userInteractionEnabled = YES;
    [self.view addSubview:scoreView];
    
    UIButton *scoreButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 30)];
    [scoreButton setTitle:@"积分" forState:UIControlStateNormal];
    [scoreButton addTarget:self action:@selector(scoreAction) forControlEvents:UIControlEventTouchUpInside];
    [scoreButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [scoreView addSubview:scoreButton];
    
    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc]initWithCustomView:scoreView];
    self.navigationItem.rightBarButtonItem = rightButtonItem;
    // Do any additional setup after loading the view.
    
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 64, kWidth, 120)];
    [self.view addSubview:view];
    
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kWidth, 40)];
    titleLabel.text = @"积分明细";
    titleLabel.font = [UIFont systemFontOfSize:18.0f];
    titleLabel.textColor = [UIColor lightGrayColor];
    [view addSubview:titleLabel];
    
    UIView *seperatorLine = [[UIView alloc]initWithFrame:CGRectMake(0, titleLabel.bottom, kWidth, 2)];
    seperatorLine.backgroundColor = [UIColor lightGrayColor];
    [view addSubview:seperatorLine];
    
    CGFloat y = seperatorLine.bottom + 2;
    
    for (int i = 1; i <= 2; i++) {
        
        CGFloat height = 0.0;
        
        for (int index = 0; index < _titleArray.count; index++ ) {
            
            UILabel *titleListLabel = [[UILabel alloc]init];
            NSString *title = [_titleArray objectAtIndex:index];
            CGFloat width = kWidth / _titleArray.count;
            titleListLabel.frame = CGRectMake(width * index, y, width, 30);
            titleListLabel.text =title;
            titleListLabel.font = [UIFont systemFontOfSize:15.0f];
            titleListLabel.textColor = [UIColor lightGrayColor];
            height = titleListLabel.bottom;
            [view addSubview:titleListLabel];
            
        }
        
        UIView *separateTitleLine = [[UIView alloc]init];
        separateTitleLine.frame = CGRectMake(0, height + 1, kWidth, 2);
        separateTitleLine.backgroundColor = [UIColor lightGrayColor];
        [view addSubview:separateTitleLine];
        
        
        y = separateTitleLine.bottom + 2;
    }
    
    UILabel *totalScoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth - 140, view.bottom, 60, 40)];
    totalScoreLabel.text = @"总积分:";
    totalScoreLabel.textColor = [UIColor lightGrayColor];
    totalScoreLabel.font = [UIFont systemFontOfSize:16.0f];
    totalScoreLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:totalScoreLabel];
    
    UILabel *scoreNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(totalScoreLabel.right, view.bottom, 40, 40)];
    scoreNumLabel.text = @"200";
    scoreNumLabel.textColor = MAIN_BLUE_COLOR;
    scoreNumLabel.font = [UIFont systemFontOfSize:20.0f];
    scoreNumLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:scoreNumLabel];
    
    UILabel *scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(scoreNumLabel.right, view.bottom, 20, 40)];
    scoreLabel.text = @"分";
    scoreLabel.textColor = MAIN_BLUE_COLOR;
    scoreLabel.font = [UIFont systemFontOfSize:20.0f];
    scoreLabel.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:scoreLabel];
    
    
    
    UIView *rangeView = [[UIView alloc]initWithFrame:CGRectMake(0, kHeight/2 , kWidth, 40)];
    [self.view addSubview:rangeView];
    
    UILabel *rangeLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth/2 - 180/2, 0 , 120, 40)];
    rangeLabel.text = @"小区内排名:";
    rangeLabel.textColor = MAIN_BLUE_COLOR;
    rangeLabel.font = [UIFont systemFontOfSize:20.0f];
    rangeLabel.textAlignment = NSTextAlignmentLeft;
    [rangeView addSubview:rangeLabel];
    
    UILabel *rangeNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(rangeLabel.right, 0 , 60, 40)];
    rangeNumLabel.text = @"329";
    rangeNumLabel.textColor = MAIN_BLUE_COLOR;
    rangeNumLabel.font = [UIFont systemFontOfSize:20.0f];
    rangeNumLabel.textAlignment = NSTextAlignmentLeft;
    [rangeView addSubview:rangeNumLabel];
    
    UILabel *shuomingLabel = [[UILabel alloc]initWithFrame:CGRectMake(15,rangeNumLabel.bottom, 100, 20)];
    shuomingLabel.text = @"您击败了本小区";
    shuomingLabel.textColor = MAIN_BLUE_COLOR;
    shuomingLabel.font = [UIFont systemFontOfSize:14.0f];
    shuomingLabel.textAlignment = NSTextAlignmentLeft;
    [rangeView addSubview:shuomingLabel];
    
    UILabel *shuomingNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(shuomingLabel.right,rangeNumLabel.bottom, 35, 20)];
    shuomingNumLabel.text = @"39%";
    shuomingNumLabel.textColor = MAIN_BLUE_COLOR;
    shuomingNumLabel.font = [UIFont systemFontOfSize:14.0f];
    shuomingNumLabel.textAlignment = NSTextAlignmentLeft;
    [rangeView addSubview:shuomingNumLabel];
    
    
    UILabel *shuomingLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(shuomingNumLabel.right,rangeNumLabel.bottom, 160, 20)];
    shuomingLabel2.text = @"的业主，请再接再厉哦！";
    shuomingLabel2.textColor = MAIN_BLUE_COLOR;
    shuomingLabel2.font = [UIFont systemFontOfSize:14.0f];
    shuomingLabel2.textAlignment = NSTextAlignmentLeft;
    [rangeView addSubview:shuomingLabel2];
    
 
    
}

-(void)scoreAction{
    
    MyScoreDetailViewController *myScoreDVC = [[MyScoreDetailViewController alloc]init];
    myScoreDVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:myScoreDVC animated:YES];
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
